package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.exception.CustomException;
import com.cskaoyan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author stone
 * @date 2022/08/10 09:34
 */
@RestController
public class HelloController {

    @Autowired
    UserService userService;

    @RequestMapping("hello")
    public BaseRespVo hello() {
        int i = 1 / 0;
        return BaseRespVo.ok("hello");
    }

    @RequestMapping("user/create")
    public BaseRespVo createUser(Integer age) throws CustomException {
        int user = userService.createUser(age);
        /*if (user == -1) {
            return BaseRespVo.fail();
        }*/
        return BaseRespVo.ok("成功");
    }
}
